//
//  BA_BusinessHelper.m
//  BaseProject
//
//  Created by 王洋 on 2020/12/29.
//  Copyright © 2020 王洋. All rights reserved.
//
#import "LSTPopView.h"

#import <BRPickerView.h>

#import "LatestContactInfoRequest.h"
#import "SubscribeStoreRequest.h"
#import "TT_WebView.h"
#import "BA_BusinessHelper.h"

@interface BA_BusinessHelper ()

@property (nonatomic, assign) NSInteger retryCount;

@property (nonatomic, weak) LSTPopView *popView;

@property (nonatomic, strong) SubscribeModel *subscribeModel;

@end

@implementation BA_BusinessHelper

+ (BA_BusinessHelper *)shared {
    
    static BA_BusinessHelper *shareInstance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken,^{
        shareInstance = [BA_BusinessHelper new];
        shareInstance.browseSellerIds = @[].mutableCopy;
        
        [[TTUserModel sharedObject].userModelDefault setDouble:0.0 forKey:@"TT_productcommission"];;
        [[TTUserModel sharedObject].userModelDefault setDouble:0.6 forKey:@"TT_packageCommission"];;
        
        shareInstance.retryCount = 0;
    });
    return shareInstance;
}

- (void)firstInstallPush {
    [self request_firstInstallPush];
}

- (void)syncBusinessData {
    //获取一些业务的基本信息
    NSMutableDictionary *dic = @{}.mutableCopy;
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,@"/indexApp/getCommonParam"];
    WEAKSELF
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        if ([data isKindOfClass:[NSDictionary class]]) {
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                NSDictionary *resultDic = [data valueForKey:@"data"];
                NSInteger userProportion = [[resultDic valueForKey:@"userProportion"] integerValue];
                NSInteger taxPoint = [[resultDic valueForKey:@"taxPoint"] integerValue];

                weakSelf.retryCount = 0;
                [[TTUserModel sharedObject].userModelDefault setInteger:userProportion forKey:@"TT_userProportion"];;
                [[TTUserModel sharedObject].userModelDefault setInteger:taxPoint forKey:@"TT_taxPoint"];;

                [[TTUserModel sharedObject].userModelDefault synchronize];
            } else {
                [weakSelf retrySyncBusinessData];
            }
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        [weakSelf retrySyncBusinessData];
    }];
}

- (void)retrySyncBusinessData {
    if (self.retryCount < 10) {
        [self syncBusinessData];
        self.retryCount++;
    } else { return; }
}

- (NSInteger)userProportion {
    NSInteger TT_userProportion = [[TTUserModel sharedObject].userModelDefault integerForKey:@"TT_userProportion"];
    return TT_userProportion;
}

- (NSInteger)taxPoint {
    NSInteger TT_taxPoint = [[TTUserModel sharedObject].userModelDefault integerForKey:@"TT_taxPoint"];
    return TT_taxPoint;
}


//婚礼倒计时
#pragma mark ------  婚礼倒计时  ------
- (void)callMarryCountDownViewWithType:(MarryCountPlaceType)type {
    self.countDownPlaceType = type;
    [self request_marryDay];
}

#pragma mark ------  预约业务  ------
- (void)callSubscribeStoreWith:(NSString *)sellerId {
    self.sellerId = sellerId;
    [self showSubscribeView];
}

#pragma mark ------  公告业务  ------
- (void)callNoticeWith:(NSString *)title And:(NSString *)content {
    [self showNoticeWith:title And:content];
}

#pragma mark ------  IM业务  ------
- (void)callIMViewWith:(BusinessActionType)type {
    [self showImWith:type];
}

- (void)callSimpleWebWith:(NSString *)url htmlStr:(NSString *)htmlStr {
    
    TT_WebView *webview = [[NSBundle mainBundle] loadNibNamed:@"TT_WebView"owner:nil options:nil].firstObject;
    webview.frame = CGRectMake(10, 10, TTScreenWidth,TTScreenHeight - kStatusBarHeight);
    LSTPopView *popView = [LSTPopView initWithCustomView:webview
                                                popStyle:LSTPopStyleSmoothFromBottom
                                            dismissStyle:LSTDismissStyleSmoothToBottom];
    self.popView = popView;
    [webview loadWithUrl:url htmlStr:htmlStr];
    popView.hemStyle = LSTHemStyleBottom;
    LSTPopViewWK(popView)
    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    popView.bgClickBlock = ^{
        [wk_popView dismiss];
    };
    webview.TT_WebViewCloseBlock = ^{
        [wk_popView dismiss];
    };
    
    [popView pop];
}

#pragma mark ------  新用户  ------
- (void)callNewUserViewComption:(void (^)(HomeADViewActionType type))comption {
    
    HomeADView *adView = [[NSBundle mainBundle] loadNibNamed:@"HomeADView"owner:nil options:nil].firstObject;

    adView.frame = CGRectMake(0, 0, TTScreenWidth - 100,(TTScreenWidth - 100) * 1.2);
    LSTPopView *popView = [LSTPopView initWithCustomView:adView
                                                popStyle:LSTPopStyleSpringFromTop
                                            dismissStyle:LSTDismissStyleSmoothToBottom];
    self.popView = popView;
    popView.hemStyle = LSTHemStyleCenter;
    LSTPopViewWK(popView)
    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    popView.bgClickBlock = ^{
        [wk_popView dismiss];
        comption(HomeADViewActionType_close);
    };
    
    adView.HomeADViewBlock = ^(HomeADViewActionType type) {
        [wk_popView dismiss];
        comption(type);
    };
    [popView pop];
}

- (void)showNoticeWith:(NSString *)title And:(NSString *)content {
    StoreDetailNoticeView *noticeView = [[NSBundle mainBundle] loadNibNamed:@"StoreDetailNoticeView"owner:nil options:nil].firstObject;
    noticeView.frame = CGRectMake(10, 10, TTScreenWidth,300);
    noticeView.itemTitle = title;
    noticeView.itemContent = content;
    LSTPopView *popView = [LSTPopView initWithCustomView:noticeView
                                                popStyle:LSTPopStyleSmoothFromBottom
                                            dismissStyle:LSTDismissStyleSmoothToBottom];
    self.popView = popView;
    popView.hemStyle = LSTHemStyleBottom;

    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    LSTPopViewWK(popView)
    popView.bgClickBlock = ^{
        [wk_popView dismiss];
    };
    
    noticeView.StoreDetailNoticeViewBlock = ^{
        [wk_popView dismiss];
    };
    
    [popView pop];
}

- (void)showImWith:(BusinessActionType)type {
    
    IMAlertView *imView = [[NSBundle mainBundle] loadNibNamed:@"IMAlertView"owner:nil options:nil].firstObject;
    imView.frame = CGRectMake(0, 0, 300,500);
    LSTPopView *popView = [LSTPopView initWithCustomView:imView
                                                popStyle:LSTPopStyleSmoothFromBottom
                                            dismissStyle:LSTDismissStyleCardDropToTop];
    self.popView = popView;
    popView.hemStyle = LSTHemStyleCenter;
    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    LSTPopViewWK(popView)
    popView.bgClickBlock = ^{
        [wk_popView dismiss];
    };
    
    imView.IMAlertViewBlock = ^(IMAlertViewActionType type) {
        [wk_popView dismiss];
        switch (type) {
            case IMAlertViewActionType_handle:{
                [[TT_IMContactManager manager] ImContactWithType:TT_IMContactType_tongchoushi];
            } break;
            case IMAlertViewActionType_close:{} break;
            case IMAlertViewActionType_call:{
                [Utilities callPhone:@"4006218520"];
            } break;
            default:
                break;
        }
    };
    
    [popView pop];
}

- (void)showSubscribeView {
    
    StoreDetailSubscribeView *subscribeView = [[NSBundle mainBundle] loadNibNamed:@"StoreDetailSubscribeView"owner:nil options:nil].firstObject;
    self.subscribeModel = [[SubscribeModel alloc] init];
    
    WEAKSELF
    [LatestContactInfoRequest request_latestContactInfoComption:^(BOOL success, LatestUserInfoModel * _Nonnull model) {
        if (success) {
            subscribeView.nameTF.text = model.userName;
            subscribeView.phoneTF.text = model.userTel;
            weakSelf.subscribeModel.cdUserName = model.userName;
            weakSelf.subscribeModel.cdUserTel = model.userTel;
        }
    }];
    
    subscribeView.frame = CGRectMake(10, 10, TTScreenWidth,300);
    LSTPopView *popView = [LSTPopView initWithCustomView:subscribeView
                                                popStyle:LSTPopStyleSmoothFromBottom
                                            dismissStyle:LSTDismissStyleSmoothToBottom];
    self.popView = popView;
    popView.hemStyle = LSTHemStyleBottom;

    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;
    
    LSTPopViewWK(popView)
    popView.bgClickBlock = ^{
        [wk_popView dismiss];
    };
    
    LSTPopViewWK(subscribeView);
    subscribeView.StoreDetailSubscribeBlock = ^(StoreDetailSubscribeViewActionType type) {
        switch (type) {
            case StoreDetailSubscribeViewActionType_selTime:{
                
                [BRDatePickerView showDatePickerWithMode:BRDatePickerModeYMDHM title:@"选择预约时间" selectValue:@"" minDate:[Utilities getDateWithTimestamp:[Utilities getCurrentTimestamp]] maxDate:[NSDate br_setYear:2050 month:12 day:1] isAutoSelect:NO resultBlock:^(NSDate * _Nullable selectDate, NSString * _Nullable selectValue) {
                    wk_subscribeView.arriveTimeLab.text = selectValue;
                    weakSelf.subscribeModel.cdAppointmentTime = selectValue;
                    wk_subscribeView.arriveTimeLab.textColor = UIColorHex(0x333333);
                }];
                
            } break;
            case StoreDetailSubscribeViewActionType_handle:{
                
                weakSelf.subscribeModel.cdUserName = wk_subscribeView.nameTF.text;
                weakSelf.subscribeModel.cdUserTel = wk_subscribeView.phoneTF.text;
                [SubscribeStoreRequest request_subscribeStoreWithModel:weakSelf.subscribeModel AndSeller:weakSelf.sellerId comption:^(BOOL success) {
                    if (success) {
                        [wk_popView dismiss];
                        [wk_subscribeView clearView];
                        weakSelf.subscribeModel = [[SubscribeModel alloc] init];
                        [weakSelf clearBrowseData];
                    } else {
                        
                    }
                }];
            } break;
            default:
                break;
        }
    };
    
    [popView pop];
}

- (void)showCountDown:(WeddingCountDownModel *)model type:(WeddingCountViewType)type {
    [self.popView dismiss];
    
    WeddingCountDownView *countDownView = [[NSBundle mainBundle] loadNibNamed:@"WeddingCountDownView"owner:nil options:nil].firstObject;;
    countDownView.frame = CGRectMake(0, 0, 300,500);
    LSTPopView *popView = [LSTPopView initWithCustomView:countDownView
                                                popStyle:LSTPopStyleSpringFromTop
                                            dismissStyle:LSTDismissStyleSmoothToBottom];
    self.popView = popView;
    popView.hemStyle = LSTHemStyleCenter;
    [countDownView fillViewWithModel:model type:type];

    WEAKSELF
    popView.popDuration = 0.5;
    popView.dismissDuration = 0.5;
    popView.isClickFeedback = YES;

    LSTPopViewWK(popView)
    popView.bgClickBlock = ^{
        [wk_popView dismiss];
    };
    [popView pop];

    countDownView.WeddingCountDownBlock = ^(WeddingCountActionType type, NSString * _Nonnull selectDate) {
        
        [wk_popView dismiss];
        switch (type) {
            case WeddingCountActionType_close:{
            } break;
            case WeddingCountActionType_update:{
                
                if (selectDate.length == 0) {//没选择日期
                    if ([TTUserModel sharedObject].marryTime.length == 0) {//如果没有就设置今天
                        NSDateFormatter * formatter=[[NSDateFormatter alloc] init];
                        [formatter setDateFormat:@"yyyy-MM-dd"];
                        NSString *noselDate = [Utilities getTimeFromTimestamp:[Utilities getCurrentTimestamp] AndFormater:formatter];
                        [weakSelf request_updateMarryDayWithSelectDate:noselDate];
                    } else {
                        [weakSelf request_updateMarryDayWithSelectDate:[TTUserModel sharedObject].marryTime];
                    }
                } else {
                    [weakSelf request_updateMarryDayWithSelectDate:selectDate];
                }
                
            } break;
            default:
                break;
        }
    };
}

//发送一条信息、成功提交订单、成功预约 就重新统计浏览的店
- (void)clearBrowseData {
    self.browseSellerIds = @[].mutableCopy;
}

- (void)browseStore:(NSString *)sellerId type:(BusinessActionType)type comption:(void (^)(BOOL success))comption {
    
    if (![self.browseSellerIds containsObject:sellerId]) {
        if (sellerId.length == 0) {
            return;
        }
        [self.browseSellerIds addObject:sellerId];
        if (self.browseSellerIds.count == 6) {
            [self callIMViewWith:type];
            [self clearBrowseData];
            comption(YES);
        }
    }
}

- (SubscribeModel *)subscribeModel {
    if (!_subscribeModel) {
        _subscribeModel = [[SubscribeModel alloc] init];
    }
    return _subscribeModel;
}

#pragma mark 收藏店铺
- (void)callCollectStoreWith:(NSString *)baseId currentStatus:(BOOL)isCollect type:(BusinessCollectType)type comption:(void (^)(BOOL success))comption {

    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setValue:baseId forKey:@"baseId"];
    [dic setValue:@(type) forKey:@"collectType"];
    if (isCollect) {
        [dic setValue:@(1) forKey:@"isDel"];
    } else {
        [dic setValue:@(2) forKey:@"isDel"];
    }
    
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"userId"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_AddCollect];
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                
                [SVProgressHUD showSuccessWithStatus:[data valueForKey:@"message"]];
                [SVProgressHUD dismissWithDelay:1];
                comption(YES);
                
            } else {
               [SVProgressHUD showErrorWithStatus:[data valueForKey:@"message"]];
               [SVProgressHUD dismissWithDelay:1];
                comption(NO);

           }
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        comption(NO);
    }];
}

#pragma mark 获取优惠券
- (void)callgetCouponWith:(NSString *)baseId And:(NSString *)sellerId comption:(void (^)(BOOL success))comption {

    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setValue:baseId forKey:@"sysCouponId"];
    [dic setValue:sellerId forKey:@"sellerId"];
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"userId"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_getCoupon];
    
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                
                NSString *msg = [data valueForKey:@"message"];
                [SVProgressHUD showSuccessWithStatus:msg];
                [SVProgressHUD dismissWithDelay:1];
                comption(YES);

            } else {
                [SVProgressHUD showErrorWithStatus:[data valueForKey:@"message"]];
                [SVProgressHUD dismissWithDelay:1];
                comption(NO);
            }
        }
        
    } FailedBlock:^(NSError * _Nonnull error) {
        comption(NO);
    }];
}

- (void)request_marryDay {
    
    if ([TTUserModel sharedObject].userId.length == 0) {
        return;
    }
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"userId"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_GetMarryDay];
    
    WEAKSELF
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {

        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            
            WeddingCountViewType viewType = WeddingCountViewType_None;

            if (code == 10000) {
                NSDictionary *resultDic = [data valueForKey:@"data"];
                
                if ([resultDic isKindOfClass:[NSDictionary class]]) {
                    WeddingCountDownModel *model = [WeddingCountDownModel modelWithDictionary:resultDic];
                                            
                    [[NSUserDefaults standardUserDefaults] setDouble:[Utilities getCurrentTimestamp] forKey:@"BA_homeMarryDayAlert"];
                    [[NSUserDefaults standardUserDefaults] synchronize];
                    //看看今天有没有弹，没有弹得就弹下
                    
                    switch (weakSelf.countDownPlaceType) {
                        case MarryCountPlaceType_home:{
                            
                            if (model.betweenDate >= 0) {
                                viewType = WeddingCountViewType_Sel;
                                [weakSelf showCountDown:model type:viewType];

                            } else {
                                return;
                            }
                        } break;
                        case MarryCountPlaceType_mine:{
                            viewType = WeddingCountViewType_Edit;
                            [weakSelf showCountDown:model type:viewType];

                        } break;
                        case MarryCountPlaceType_setting:{
                            viewType = WeddingCountViewType_Edit;
                            [weakSelf showCountDown:model type:viewType];

                        } break;
                        default:
                            break;
                    }
                }
            } else {
                
                if (code != 10005) {
                    switch (weakSelf.countDownPlaceType) {
                        case MarryCountPlaceType_home:{
                            viewType = WeddingCountViewType_None;
                            [[NSUserDefaults standardUserDefaults] setDouble:[Utilities getCurrentTimestamp] forKey:@"BA_homeMarryDayAlert"];
                            [[NSUserDefaults standardUserDefaults] synchronize];
                            
                        } break;
                        case MarryCountPlaceType_mine:{
                            viewType = WeddingCountViewType_None;
                        } break;
                        case MarryCountPlaceType_setting:{
                            viewType = WeddingCountViewType_None;
                        } break;
                        default:
                            break;
                    }
                    WeddingCountDownModel *model = [[WeddingCountDownModel alloc] init];
                    [weakSelf showCountDown:model type:WeddingCountViewType_None];
                }
            }
        } else {
            [SVProgressHUD showErrorWithStatus:[data valueForKey:@"message"]];
            [SVProgressHUD dismissWithDelay:1];
        }
        
    } FailedBlock:^(NSError * _Nonnull error) {
        
    }];
}

#pragma mark 更新婚礼倒计时时间
- (void)request_updateMarryDayWithSelectDate:(NSString *)dateValue {
    
    NSLog(@"调用更新接口");
    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setValue:dateValue forKey:@"marryTime"];
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"userId"];
    
    NSLog(@"调用更新接口-%@",dic);
    
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_EditMyInfo];
    WEAKSELF
    [SVProgressHUD showWithStatus:@"正在加载"];
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        
        [SVProgressHUD dismiss];
        if ([data isKindOfClass:[NSDictionary class]]) {
            //请求成功
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            NSLog(@"更新接口返回-%@",data);

            if (code == 10000) {
                if ([BA_BusinessHelper shared].BusinessHelperDismissBlock) {
                    [BA_BusinessHelper shared].BusinessHelperDismissBlock(YES);
                }
            } else {
                if ([BA_BusinessHelper shared].BusinessHelperDismissBlock) {
                    [BA_BusinessHelper shared].BusinessHelperDismissBlock(NO);
                }
            }
        }
        
    } FailedBlock:^(NSError * _Nonnull error) {
        [SVProgressHUD dismiss];
        if (weakSelf.BusinessHelperDismissBlock) {
            weakSelf.BusinessHelperDismissBlock(NO);
        }
    }];
}

#pragma mark 第一次安装获取推送
- (void)request_firstInstallPush {
    //如果推过就不推
    NSString *isPush = [Utilities getFromNSUserDefaults:@"BA_firstInstallPush"];
    if ([isPush isEqualToString:@"1"]) { return; }
    NSMutableDictionary *dic = @{}.mutableCopy;
    NSString *rid = [Utilities getFromNSUserDefaults:@"BA_registrationID"];
    [dic setValue:rid forKey:@"registrationID"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,@"/indexApp/firstInstallPush"];
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        if ([data isKindOfClass:[NSDictionary class]]) {
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) { [Utilities setToNSUserDefaults:@"BA_firstInstallPush" value:@"1"];}
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        
    }];
}

#pragma mark 实时统计接口
- (void)addFootPrintWith:(NSString *)baseId lastTime:(NSTimeInterval)lastTime And:(NSString *)sellerId type:(BusinessCollectType)type {

    NSMutableDictionary *dic = @{}.mutableCopy;
    [dic setValue:baseId forKey:@"baseId"];
    [dic setValue:sellerId forKey:@"sellerId"];
    //足迹类型1商家2套餐3作品4婚品
    [dic setValue:@(type) forKey:@"footType"];
    [dic setValue:@(lastTime) forKey:@"lastTime"];
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"userId"];
        
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,API_AddFootPrint];
    [TTHttpManager postRequestWithUrl:url
                              TimeOut:10
                             PostData:dic
                          FinishBlock:^(id  _Nonnull data) {
}
                          FailedBlock:^(NSError * _Nonnull error) {}];
}

#pragma mark 更新客资信息
- (void)request_updateInfoWithSellerId:(NSString *)sellerId phoneNo:(NSString *)phoneNo andWechatId:(NSString *)wechatId comption:(void (^)(BOOL success))comption {
    
    NSMutableDictionary *dic = @{}.mutableCopy;
    if (phoneNo.length > 0) {[dic setValue:phoneNo forKey:@"userTel"];}
    if (wechatId.length > 0) {[dic setValue:wechatId forKey:@"userWeChat"];}
    [dic setValue:sellerId forKey:@"sellerId"];
    [dic setValue:[TTUserModel sharedObject].userId forKey:@"userId"];
    NSString *url = [NSString stringWithFormat:@"%@%@",TT_Global_Api_Domain,@"/indexApp/updateCustomerData"];
    
    [TTHttpManager postRequestWithUrl:url TimeOut:10 PostData:dic FinishBlock:^(id  _Nonnull data) {
        if ([data isKindOfClass:[NSDictionary class]]) {
            NSInteger code = [[data valueForKey:@"code"] integerValue];
            if (code == 10000) {
                comption(YES);
            } else {
                comption(NO);
            }
        }
    } FailedBlock:^(NSError * _Nonnull error) {
        comption(NO);
    }];
}



@end
